<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Add Gallery</title>
<script type="text/javascript" src="/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="/js/fullhappy.cookie.js"></script>
<script type="text/javascript" src="/js/lightbox/lightBox.js"></script>
</head>
<body style="width: 230px; height:40px; margin: 0 ;text-align: center;">
	<form>
		<input style="width: 150px;" id="new_category_name" type="text"
			placeholder="" />
		<input type="button" onclick="editCategory();"
			value="save"/>
	</form>
	<script type="text/javascript">		
		$('input[type = "text"]').attr('placeholder',window.location.search.substr(1).split('&')[1]);
		function editCategory(){
			var newCategoryName = document.getElementById('new_category_name').value;
			newCategoryName = newCategoryName.trim();
			if(newCategoryName.length<=0){
				return false;
			}else{			 
                 var xhr = new XMLHttpRequest();
                 var categoryId =  window.location.search.substr(1).split('&')[0];
                 xhr.open("POST","/rest/process/edit_category",true);
                 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
                 xhr.send("category_id="+categoryId+"&new_category_name="+newCategoryName);
                 xhr.onload = function(e) {
                     if (this.status == 200) {
                    	 (new HappyLightBox()).innerClose();
                     }
                 };                    
			}
				
		};
	</script>
</body>
</html>